package com.topnav.mc.admin.entity.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 操作功能
 * @Author: kenny
 * @Date: 2024/3/29 16:53
 */
public enum EnumOperateFunction {
    SYSTEM(1,"系统","system")
    ,FENCE(2,"围栏","p_fence_maintain")
    ,DEVICE(3,"设备","p_device_manage")
    ,USER(4,"用户","p_user_reg")
    ,ORGANIZATION(5,"组织机构管理","p_organization_reg");

    private int code;
    private String engKey;
    private String desc;

    private EnumOperateFunction(Integer code, String desc,String engKey) {
        this.code = code;
        this.engKey = engKey;//前端有语言翻译
        this.desc = desc;
    }

    public int getCode() {return code;}
    public void setCode(int code) {this.code = code;	}
    public String getEngKey() {return engKey;}
    public void setEngKey(String EngKey) {this.engKey = EngKey;}
    public String getDesc() {return desc;}
    public void setDesc(String desc) {this.desc = desc;}

    public static EnumOperateFunction getByCode(int code) {
        for (EnumOperateFunction enumEntity : EnumOperateFunction.values()) {
            if (enumEntity.getCode() == code) {
                return enumEntity;
            }

        }
        return null;
    }
    public static List<EnumModal> toList(){
        List<EnumModal> list = new ArrayList<>();
        for (EnumOperateFunction bean : EnumOperateFunction.values()) {
            EnumModal enumModal = new EnumModal();
            enumModal.setIndex(bean.ordinal());
            enumModal.setCode(bean.getCode());
            enumModal.setName(bean.name());
            enumModal.setDesc(bean.getEngKey());
            list.add(enumModal);
        }
        return list;
    }
}
